-
-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Part of Android Support: screenshot testing #4411
Part of Android Support: screenshot testing #4411
Conversation
prototyping Progressing Compiling Generates screenshots Cleanups and fmt
there is a failure in the javalib native examples, but I don't think it's related to my changes. |
example/android/kotlinlib/3-compose-screenshot-tests/app/src/main/AndroidManifest.xml
Show resolved
Hide resolved
I think the code looks fine, just some comments about the provenance of the code to better understand why it is the way it is. For some reason Github is not letting me resolve the branch conflict, so you may have to tick the checkbox in the PR to let maintainers update it |
e46627e
to
a46eddd
Compare
thanks, there were conflicts with the main branch, T.log => Task.log, so I changed that bit of code on this PR as per your recommendation |
Background
Screenshot testing is a way to test UIs and in Android's case, typically without the need of running an emulator. This is achieved in recent developments with the usage of Compose and Previews (the same functionality that generates previews in android studio).
The typical flow is:
Further Reading: https://developer.android.com/studio/preview/compose-screenshot-testing
Provided in this PR
This PR, while it has in mind the full flow support, only provides the means to generate screenshots and run diffs with the same tools that AGP is using. At the same time, we keep the test task compatibility with Mill so we don't need to implement any custom runner tasks.
Generating screenshots
Using the same tool as AGP, the compose-preview-renderer, which has undocumented cli arguments. However, these can be found by running the respective gradle task in a sample Android studio project
Then, given the generated data, the PR worked towards generating the file computing classpaths and other needed files similarly
Currently these screenshots are ephemeral, and this PR is not concerned by adding support for version control on the screenshot base. The plan is for a future PR to make it easier for the users to customise the behaviour (e.g. choose the path)
Testing screenshots
AGP uses the screenshot-validation-junit-engine. This PR provides similar functionality but hooking into Mill's testing infrastructure instead of Gradle.
Example App
The example App was set up initially with AGP and then a mill version was constructed with 2 differences:
Future developments / Not yet implemented in this PR